package com.quanyan.orderpay.service.check.account.impl;

import com.quanyan.orderpay.constants.AccountWaterDataSourceConstants;
import com.quanyan.orderpay.constants.AccountWaterTradeTypeConstants;
import com.quanyan.orderpay.service.check.account.WaterMessageDecoder;
import com.quanyan.pay.api.chinaums.vo.UmBillDataItem;
import com.quanyan.pay.entity.AccountPayWater;
import org.springframework.stereotype.Component;


/**
 * Created by pp.zuo on 2017/3/29.
 */
@Component("chinaumsMessageDecoder")
public class ChinaumsMessageDecoder implements WaterMessageDecoder {
    /**
     * @param messageObject String[]
     * @return
     */
    @Override
    public AccountPayWater decode(Object messageObject) {
        AccountPayWater accountPayWater = new AccountPayWater();

        UmBillDataItem item = (UmBillDataItem)messageObject;

        accountPayWater.setOrderNo("");
        accountPayWater.setOutTradeNo(item.getReferenceNo());
        accountPayWater.setAccountTime(item.getTradeTime());
        accountPayWater.setAmount(item.getTradeFee());
        accountPayWater.setDataSource(AccountWaterDataSourceConstants.CHINA_UMS);
        accountPayWater.setTradeType(AccountWaterTradeTypeConstants.TRADE);
        accountPayWater.setBuyerAccount(item.getCardNo());

        return accountPayWater;
    }
}
